package empox.pos.system.pos;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class SystemPosInfoAdapter extends BaseAdapter {
	Context showCon;
	String[] n;
	String[] v;
	String[] s;

	public SystemPosInfoAdapter(Context mContext) {
		showCon = mContext;
	}

	public void setValue(String[] name, String[] value, String[] show) {
		n = name;
		v = value;
		s = show;
	}

	public int getCount() {
		if (n != null) {
			return n.length;
		}
		return 0;
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	static class SH {
		TextView tv1;
		TextView tv2;
		TextView tv3;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		SH sh = new SH();

		if (convertView == null) {
			convertView = new LinearLayout(showCon);
			((LinearLayout) convertView).setGravity(Gravity.CENTER);

			sh.tv1 = new TextView(showCon);
			sh.tv1.setWidth(250);
			sh.tv1.setHeight(30);
			sh.tv1.setGravity(Gravity.CENTER);
			sh.tv1.setTextColor(0xff57290a);
			((LinearLayout) convertView).addView(sh.tv1);

			sh.tv2 = new TextView(showCon);
			sh.tv2.setWidth(250);
			sh.tv2.setHeight(30);
			sh.tv2.setGravity(Gravity.CENTER);
			sh.tv2.setTextColor(0xff57290a);
			((LinearLayout) convertView).addView(sh.tv2);

			if (s != null) {
				sh.tv3 = new TextView(showCon);
				sh.tv3.setWidth(250);
				sh.tv3.setHeight(30);
				sh.tv3.setGravity(Gravity.CENTER);
				sh.tv3.setTextColor(0xff57290a);
				((LinearLayout) convertView).addView(sh.tv3);
			}
			convertView.setTag(sh);
		} else {
			sh = (SH) convertView.getTag();
		}

		sh.tv1.setText(n[position]);
		sh.tv2.setText(v[position]);
		
		if (s != null) {
			sh.tv3.setText(s[position]);
		}
		return convertView;
	}
}
